import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  // 自定义高亮css样式类名
  linkActiveClass: 'active', // 配置模糊匹配类名
  linkExactActiveClass: 'exact-active', // 配置精确匹配类名
  routes: [
    // 首页
    {
      path: '/',
      component: () => import('@/views/index/XuanIndexViews.vue')
    },

    // 文化探索
    {
      path: '/culture',
      component: () => import('@/views/culture/XuanCultureViews.vue')
    },
    {
      path: '/culture/yy',
      component: () => import('@/views/culture/XuanYinYangViews.vue')
    },
    {
      path: '/culture/wx',
      component: () => import('@/views/culture/XuanWuXingViews.vue')
    },
    {
      path: '/culture/tg',
      component: () => import('@/views/culture/XuanTianGanViews.vue')
    },
    {
      path: '/culture/dz',
      component: () => import('@/views/culture/XuanDiZhiViews.vue')
    },
    {
      path: '/culture/bg',
      component: () => import('@/views/culture/XuanBaGuaViews.vue')
    },
    {
      path: '/culture/lssg',
      component: () => import('@/views/culture/XuanLiuShiSiGuaViews.vue')
    },
    {
      path: '/culture/bm',
      component: () => import('@/views/culture/XuanBaMenViews.vue')
    },
    {
      path: '/culture/jx',
      component: () => import('@/views/culture/XuanJiuXingViews.vue')
    },
    {
      path: '/culture/bs',
      component: () => import('@/views/culture/XuanBaShenViews.vue')
    },
    {
      path: '/culture/sx',
      component: () => import('@/views/culture/XuanShengXiaoViews.vue')
    },
    {
      path: '/culture/qmjg',
      component: () => import('@/views/culture/XuanQiMenJiGeViews.vue')
    },
    {
      path: '/culture/qmxg',
      component: () => import('@/views/culture/XuanQiMenXiongGeViews.vue')
    },

    // 辅助工具
    {
      path: '/tool',
      redirect: '/tool/bz',
      component: () => import('@/views/tool/XuanBaZiPaiPanViews.vue'),
    },
    {
      path: '/tool/qm',
      component: () => import('@/views/tool/XuanQiMenPaiPanViews.vue')
    },
    {
      path: '/tool/bz',
      component: () => import('@/views/tool/XuanBaZiPaiPanViews.vue')
    },
    {
      path: '/tool/ly',
      component: () => import('@/views/tool/XuanLiuYaoQiGuaViews.vue')
    },
    {
      path: '/tool/mhys',
      component: () => import('@/views/tool/XuanMeiHuaQiGuaViews.vue')
    },


    // 404
    {
      path: '/:catchAll(.*)',
      component: () => import('@/views/404/XuanNotFindViews.vue')
    }
  ]
})

// 全局前置守卫
router.beforeEach((to, from, next) => {
  // 将滚动位置重置为顶部
  window.scrollTo(0, 0);
  next(); // 跳转
})

// 全局解析守卫
router.beforeResolve((to, from, next) => {
  next(); // 跳转
})

// 全局后置守卫
router.afterEach((to, from) => {
})

export default router
